<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>订单结算</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <link rel="stylesheet" type="text/css" href="../css/swiper.min.css" />
    <link rel="stylesheet" type="text/css" href="../css/layer.css" />
    <link rel="stylesheet" type="text/css" href="../css/mobiscroll_002.css" >
    <link rel="stylesheet" type="text/css" href="../css/mdw.css" />
    <script type="text/javascript" src="../script/api.js"></script>
    <script type="text/javascript" src="../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../script/swiper.min.js"></script>
    <script type="text/javascript" src="../script/mobile.js"></script>
    <script type="text/javascript" src="../script/layer.js"></script>
    <script type="text/javascript" src="../script/mdw.js"></script>
    <script type="text/javascript" src="../script/jumpPage.js"></script>

    <script src="../script/mobiscroll_002.js" type="text/javascript"></script>
    <script src="../script/mobiscroll_004.js" type="text/javascript"></script>
    <script src="../script/mobiscroll.js" type="text/javascript"></script>
    <script src="../script/mobiscroll_003.js" type="text/javascript"></script>
    <script src="../script/mobiscroll_005.js" type="text/javascript"></script>

</head>
<body >
    <header class="header">
        <div class="backPrevPage" onclick="historyBack()"></div>
        <div class="pageTitle">订单结算</div>
    </header>
    <section class="addressPage HTML_BOX">
        <div class="pageTitle plr displayFlex">
            <div class="eng_title">账单地址</div>
        </div>
        <div class="addressBox1">
            <div onclick="openWin('address','address.html',{id:1})" id="zdno" class="noAddress f_c hide">添加收货地址+</div>
            <div class="addressItem zddz hide" onclick="openWin('address','address.html',{id:1})">
                <div class="icon"></div>
                <div class="itemRight">
                    <div class="item1">
                        <div class="name">张8</div>
                        <div class="phone">187****3265</div>
                    </div>
                    <div class="item2"> 重庆渝中区全境  江北区解放碑华一村   </div>
                </div>
            </div>
        </div>
        <div class="pageTitle plr displayFlex is_qunancheng">
            <div class="eng_title">收货地址</div>
            <div class="reAddress"><i></i>与账单地址一样</div>
        </div>
        <div class="addressBox1 is_qunancheng">
            <div onclick="openWin('address','address.html',{id:1})" id="shno" class="noAddress f_c hide">添加收货地址+</div>
            <div class="addressItem shdz hide" onclick="openWin('address','address.html',{id:1})">
                <div class="icon"></div>
                <div class="itemRight">
                    <div class="item1">
                        <div class="name">张笑</div>
                        <div class="phone">187****3265</div>
                    </div>
                    <div class="item2"> 重庆渝中区全境  渝中区解放碑华一村   </div>
                </div>
            </div>
        </div>
        <div class="addressBox1" style="display: none;">
            <div class="addressItem ztdz">
                <div class="icon"></div>
                <div class="itemRight">
                    <div class="item1">
                        <div class="name"></div>
                        <div class="phone"></div>
                    </div>
                    <div class="item2"></div>
                </div>
            </div>
        </div>
        <div class="bg-eee is_qunancheng" style="border-bottom:.2rem solid #EEE ; "></div>
        <div class="addressBox2 plr displayFlex is_qunancheng">
            <div class="eng_title">希望送达日期</div>
            <div class="time">
                <input style="width: 3rem;" placeholder="请选择送达时间" class="minDate text_r" readonly="readonly" name="appDateTime" id="appDateTime" type="text">
                <i style="margin-left:0.1rem;margin-bottom: 0.02rem; "></i>
            </div>
        </div>
        <div class="bg-eee" style="border-bottom:.2rem solid #EEE ; "></div>
        <div class="addressBox3 plr">
            <!-- <div class="shopName"><i></i><span class="name">恒都黑店旗舰店</span></div> -->
            <ul class="order_wareList">
               
            </ul>
            <div class="warePeiSong is_qunancheng">
                <span class="eng_title">配送方式</span>
                <select class="psfunction">
                    <option value="1" selected="selected">上门面交</option>
                    <option value="2">放在门口</option>
                    <option value="3" >自提</option>
                    <option value="4">邮寄</option>
                </select>
            </div>
            <div class="liuyanBox">
                <span class="eng_title"  style="margin-top:0.02rem;" >留言</span>
                <div class="liuyanItem">
                    <textarea autoHeight="true" placeholder="可在此添加订单备注" class="liuyanarea"></textarea>
                </div>
            </div>
        </div>
        <div class="bg-eee" style="border-bottom:.2rem solid #EEE ; "></div>
        <div class="wareOrderBox1 plr displayFlex">
            <div class="eng_title">优惠券</div>
            <div class="coupon_btn">使用优惠券<i></i></div>
        </div>
        <div class="bg-eee" style="border-bottom:.2rem solid #EEE ; "></div>
        <div class="wareOrderBox1 plr displayFlex">
            <input id="couponCode_input" placeholder="输入优惠码" />
            <div class="couponCode_btn">使用优惠码</div>
        </div>
        <div class="bg-eee" style="border-bottom:.2rem solid #EEE ; "></div>
        <ul class="odBox3">
            <li>
                <span>商品金额</span>
                <div id="" class="c_main">$0</div>
            </li>
            <li>
                <span>GST/HST</span>
                <div id="g_sui" class="c_main">$0</div>
            </li>
            <li>
                <span>PST</span>
                <div id="p_sui" class="c_main">$0</div>
            </li>
            <li>
                <span>优惠金额</span>
                <div id="" class="c_main">$0</div>
            </li>
            <li>
                <span>运费</span>
                <div id="" class="c_main">$0</div>
            </li>
            <li>
                <span>优惠券金额</span>
                <div id="" class="c_main">$0.00</div>
            </li>
            <li class="dn">
                <span>优惠码</span>
                <div id="" class="c_main">$0.00</div>
            </li>
        </ul>
        <div class="bg-eee" style="border-bottom:1.5rem solid #EEE ; "></div>
    </section>
    <section class="footer wareOrderFooter displayFlex">
        <div class="footLeft">应付金额：<span style="margin-left:0.1rem"  class="c_main">$0</span></div>
        <div class="submitBtn f_c">提交订单</div>
    </section>
    <!-- 弹窗 -->
    <div class="mask_pop">
        <div class="mask" ></div>
        <div class="orderCoPop dn pop_Item">
            <div class="pop_close2"><i class="icon"></i></div>
            <div class="notyhq" onclick="coupon(0,0)">不使用优惠券</div>
            <ul class="couponList plr">
            
           </ul>
        </div>
        <div class="coupon_pop dn pop_Item">
            <div class="coupon_popImage">
                <img src="../image/coupon_pop_bg.png"/>
            </div>
            <div id="coupon_pop_title" style="margin-top: .5rem">您当前的订单是否追加到未发货订单？</div>
            <div class="zuijiaorder" >订单号：2019042315678416</div>
            <input type="hidden" id="zjorder_val" />
            <div style="display: flex;">
                <div class="zjorder_box1 f_c">立刻追加</div>
                <div class="zjorder_box2 f_c">取消</div>
            </div>
        </div>
        <div class="zitiPop dn pop_Item">
            <div id="zitiPop_title" style="font-size:.32rem;">选择自提点</div>
            <div id="cgj" class="ztBox">
                <span>请选择国家</span><i></i>
                <input id="guojia" type="hidden" />
            </div>
            <div id="csf" class="ztBox">
                <span>请选择省份</span><i></i>
                <input id="sf" type="hidden" />
            </div>
            <div id="ccs" class="ztBox">
                <span>请选择城市</span><i></i>
                <input id="chengshi" type="hidden" />
            </div>
            <ul class="zitilist">
                
            </ul>
            <div id="coupon_close" class="pop_close"></div>
        </div>
  </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript">
    //这部分为计算运费的参数
    var f_way = 1;//选择方式
    var sh_id = 0;//收货地址id
    var zd_id = 0;//订单地址id
    var psh_id = 0;//参数中地址id
    var shopid="";//商铺id
    var wareid="";//商品id
    var total_yunfei = 0;//总运费
    var is_hexiaojia=0;//是核销价
    var no_hexiaojia=0;//是核销价
    var sumweight=0;//是核销价

    var ziti_addr = "";//自提地址

    //这部分为计算价格的参数
    var sum_price =0;//商品金额;
    var sum_youhui = 0;//会员优惠金额
    var youhuiq = 0;//优惠券金额


    var yhid =0;//优惠券id
    var param = {};
    var totalPrice = 0;
    var is_qunancheng = false;//是否是全城
    apiready = function(){
        $api.fixStatusBar($api.dom('header'));
        api.setStatusBarStyle({
            color: '#fff',//设置APP状态栏背景色
            style: 'dark'
        });
        api.addEventListener({
            name: 'order_address'
        }, function(ret, err) {
           getAddress();
        });
        choosecity();
        ifCnAndEn();
        param = api.pageParam || {};
        console.log(JSON.stringify(param));
        var lang_type = $api.getStorage('lang_type');
        if(lang_type.id == 14){
           if(cnen==1){
                 var psfunction = '<option value="1" selected="selected">上门面交</option>'+
                            '<option value="2">放在门口</option>'+
                            '<option value="3">自提</option>';
                $(".psfunction").html(psfunction);
           }else{
                var psfunction = '<option value="1" selected="selected">Delivered to Person</option>'+
                            '<option value="2">Leave at the Door</option>'+
                            '<option value="3">Self Pickup</option>';
                $(".psfunction").html(psfunction);
           }
        }else{
            var psfunction = '<option value="4" selected="selected">邮寄</option>';
            if(cnen==2){
                psfunction = '<option value="4" selected="selected">Mail</option>';
            }
            $(".psfunction").html(psfunction);
        }
        ready();
    };
    //取消追加订单
    $(".zjorder_box2").click(function(){
        maskClose();
        $(".pop_Item").addClass("dn");
        pop.loading();
        addOrder();
    })
    $(".pop_close").click(function(){
        maskClose();
        $(".pop_Item").addClass("dn");
    })
    //确定追加订单
    $(".zjorder_box1").click(function(){
        maskClose();
        $(".pop_Item").addClass("dn");
        pop.loading();
        addOrder($("#zjorder_val").val());
    })
    //提交订单，判断是否有追加订单
    $(".submitBtn").click(function(){
        var dates = $("#appDateTime").val();
        var p = {
            is_hexiaojia:is_hexiaojia,
            no_hexiaojia:no_hexiaojia,
            sh_id:psh_id,
            f_way:f_way,
            dates:dates,
            token:token
        };
        if(param.buy_type =="spell"){
            addOrder();
            return;
        }
        pop.loading();
        getAjax(Interface.append_order,p,function(res){
            console.log(JSON.stringify(res));
            if(!res.have_zj){
                addOrder();
            }else{
                //addOrder();
                if(cnen==1){
                    $(".zuijiaorder").html('订单号：'+res.data.order_number);
                }else{
                    $(".zuijiaorder").html('Order No：'+res.data.order_number);
                }
                
                $("#zjorder_val").val(res.data.order_number);
                pop.close();
                maskOpen();
                $(".coupon_pop").removeClass("dn");
            }
        },function(res,err){
            
        })
    })
    //添加订单
    function addOrder(orderid){
        if(f_way !=3){
            ziti_addr = "";
        }
        var p = {
            append_order:orderid,
            shopid:shopid,
            sh_id:psh_id,
            f_way:f_way,
            token:token,
            dates:$("#appDateTime").val(),
            coupon_id:yhid,
            remark:$("textarea").val(),
            buy_type:param.buy_type,
            product_id:wareid,
            num:param.num,
            ggtc_id:param.ggtc_id,
            jiage_type:param.jiage_type,
            group_id:param.group_id,
            carid:param.ids,
            recom_num:recom_num,
            ziti_addr:ziti_addr
        };
        
        console.log(JSON.stringify(p));
        getAjax(Interface.add_order,p,function(res){
            pop.close();
            //alert(JSON.stringify(res));//orderid,order_number,order_price
            var p = res.data;
            p.buy_type = param.buy_type;
            openWin('ware_payOrder','ware_payOrder.html',p);
        },function(res,err){
            
        })
    }
    //是否选择为账单地址
    $(".reAddress").click(function(){
        var has = $(this).hasClass("on");
        if(has){
            $(this).removeClass("on");
            psh_id = sh_id || 0;
            $(".addressBox1").eq(1).show();
        }else{
            $(this).addClass("on");
            psh_id = zd_id || 0;
            $(".addressBox1").eq(1).hide();
        }
        getYunfei();
    })
    //打开选择优惠券
    $(".coupon_btn").click(function(){
        maskOpen();
        $(".orderCoPop").removeClass("dn");
    })
    $(".pop_close2 .icon").click(function(){
        maskClose();
        $(".pop_Item").addClass("dn");
    });

    //选择配送方式
    $(".psfunction").change(function(){
        f_way = $(this).val();
        if(f_way==3){
            maskOpen();
            $(".zitiPop").removeClass("dn");
        }else{
            $(".addressBox1").eq(0).show();
            $(".addressBox1").eq(1).show();
            $(".addressBox1").eq(2).hide();
            $(".pageTitle").eq(1).show();
            $(".pageTitle").eq(2).show();
        }
       getYunfei();
       $(this).blur();
    }).focus(function(){
        $(this)[0].selectedIndex = -1;
    });
     //选择国家
    $("#cgj").click(function(){
        openWin('address_choose','address_choose.html');
    })
    //选择省份
    $("#csf").click(function(){
        var id = $("#guojia").val();
        if(id==0){
            if(cnen ==1){
                pop.notice("请选择国家");
            }else{
                pop.notice('Please choose the country');
            }
            return;
        }
        openWin('address_choose_province','address_choose_province.html',{country_id:id});
    })
    //选择城市
    $("#ccs").click(function(){
        var id = $("#sf").val();
        if(id==0){
            if(cnen ==1){
                pop.notice("请选择省份");
            }else{
                pop.notice('Please choose the province');
            }
            return;
        }
        openWin('address_choose_city','address_choose_city.html',{province_id:id});
    })
 
    
    function ready(){
        var p = {
            token:token,
            carid:param.ids,
            buy_type:param.buy_type,
            product_id:param.product_id,
            num:param.num,
            ggtc_id:param.ggtc_id,
            jiage_type:param.jiage_type
        };
        pop.loading();
        console.log(JSON.stringify(p));
        getAjax(Interface.order_info,p,function(res){
            console.log(JSON.stringify(res.data));
            var coupin_list = res.data.coupin_list;//可用优惠券
            //total_yunfei 运费//sumweight 总总量//sum_youhui 优惠价格//sum_num 总数量//sum_price 总价格
            //is_hexiaojia //no_hexiaojia//sui.g_sui G税费//sui.p_sui P税费//other_info 其他信息 无用
            is_hexiaojia = res.data.is_hexiaojia;
            total_yunfei = res.data.total_yunfei;
            no_hexiaojia = res.data.no_hexiaojia;
            sumweight = res.data.sumweight;
            sum_price = res.data.sum_price;
            sum_youhui = res.data.sum_youhui;
            $(".odBox3 li").eq(0).find("div").html('$'+Number(res.data.sum_price).toFixed(2));
            $(".odBox3 li").eq(3).find("div").html('$'+Number(res.data.sum_youhui).toFixed(2));
            var order_product = res.data.order_product;
            $.each(order_product,function(i,item){
                var html= "";
                var name = item.title;
                if(cnen ==2){
                      name = item.egname;
                } 
                if(i==0){

                    shopid +=item.shop_id;
                    wareid += item.id;
                }else{
                    shopid +=","+item.shop_id;
                    wareid += ","+item.id;
                }
                if(item.is_qunancheng == 1){
                    is_qunancheng = true;
                }
                html+='<li class="wareInfo">';
                    html+='<div class="wareImage">';
                        html+='<img src="'+getImg(item.icon)+'" />';
                    html+='</div>';
                    html+='<div class="wareData">';
                        html+='<div class="wareName"><span>'+name+'</span></div>';
                        // html+='<div class="wareGuiGe">2kg</div>';
                        html+='<div class="warePrice">';
                            html+='<div>';
                            if(item.old_price == ""){
                                  html+='<span>$'+item.new_price+'</span>';
                              }else{
                                  html+='<span>$'+item.new_price+'</span>';
                                  html+='<del>'+item.old_price+'</del>';
                              }
                            html+='</div>';
                            html+='<span class="count">x'+item.num+'</span>';
                        html+='</div>';
                    html+='</div>';
                html+='</li>';
                totalPrice+=item.new_price;
                $(".order_wareList").append(html);
            })
            if(is_qunancheng){
                $(".is_qunancheng").remove();
            }
            if(coupin_list && coupin_list.length > 0){
                var html ="";
                $.each(coupin_list,function(i,item){
                    var duihuan = '立刻使用';
                    var satisfy ='<div class="coupon_cond">满'+item.manzu+'使用</div>';
                    if(cnen==2){
                        duihuan ='Apply now';
                        item.title = item.eng_title ||" ";
                        satisfy ='<div class="coupon_cond">Over $'+item.manzu+'</div>';
                    }
                    html+='';
                    html+='<li class="on">';
                       html+='<div class="couponLeft">';
                           html+='<div class="">$<span class="coupon_price">'+item.val3+'</span></div>';
                           html+=satisfy;
                       html+='</div>';
                       html+='<div class="couponRight">';
                           html+='<div class="couponInfo">';
                               html+='<div class="couponTitle">'+item.title+'</div>';
                               html+='<div class="couponTime">'+timestampToTime(item.start_time)+'~'+timestampToTime(item.end_time)+'</div>';
                           html+='</div>';
                           html+='<div onclick="coupon(\''+item.id+'\',\''+item.val3+'\')" class="coupon_go">'+duihuan+'</div>';
                       html+='</div>';
                   html+='</li>';
                })
                
                $(".couponList").append(html);
            }else{
                if(cnen==1){
                        $(".couponList").append('<div class="pageHide">暂无数据..</div>');
                }else{
                        $(".couponList").append('<div class="pageHide">Not eigible..</div>');
                }
            }
            getAddress();
        },function(res,err){})
    }
    //使用优惠券
    function coupon(id,val){
        youhuiq = val;
        yhid = id;
        $(".odBox3 li").eq(5).find("div").html('$'+Number(val).toFixed(2));
        maskClose();
        getYunfei();

    }
    var recom_num = "";
    $(".couponCode_btn").click(function(){
        var val = $("#couponCode_input").val();
        if(val ==""){
            if(cnen ==1){
                pop.notice("请输入优惠码");
            }else{
                pop.notice("Please enter the discount code.");
            }
            return;
        }
        pop.loading();
        getAjax(Interface.recom_price,{token:token,recom_num:val,price:$(".wareOrderFooter .c_main").html().substr(1)},function(res){
            pop.close();
            recom_num = val;
            var price = $(".wareOrderFooter .c_main").html().substr(1);
            $(".wareOrderFooter .c_main").html("$"+res.data);
            $(".odBox3 li").eq(6).removeClass("dn");
            $(".odBox3 li").eq(6).find("div").html('-$'+(Number(price).toFixed(2) - Number(res.data).toFixed(2)).toFixed(2));
        },function(res,err){})
    })


    //获取地址
    function getAddress(){
        pop.loading();
        getAjax(Interface.address_list,{token:token,type:2},function(res){
            console.log(JSON.stringify(res));
            api.hideProgress();
            var zd = res.data.zdaddress;
            var sh =null;
            if(res.data.shaddress){
                sh = res.data.shaddress[0];
            }
            if(zd.address){
                $(".reAddress").show();
                zd_id = zd.id;
                if(zd.name==null){
                    zd.name ="";
                }
                if(!zd.city_name){
                    zd.city_name = "";
                }
                if(!zd.other_cities){
                    zd.other_cities = zd.city_name;
                }
                $(".zddz .name").text(zd.username+" "+zd.name);
                $(".zddz .phone").text(zd.mobile);
                $(".zddz .item2").html(zd.address+zd.gongyu+", "+zd.other_cities+"<br/>"+zd.province_name+", "+zd.country_name+" "+zd.you_code);
                $(".zddz").removeClass("hide");
                $("#zdno").addClass("hide");
            }else{
                $(".reAddress").hide();
                $("#zdno").removeClass("hide");
            }
            if(sh){
                sh_id=sh.id;
                psh_id=sh.id || 0;
                if(sh.name==null){
                    sh.name ="";
                }
                if(!sh.city_name){
                    sh.city_name = "";
                }
                if(!sh.other_cities){
                    sh.other_cities = sh.city_name;
                }
            
                $(".shdz .name").text(sh.username+" "+sh.name);
                $(".shdz .phone").text(sh.mobile);
                $(".shdz .item2").html(sh.address+sh.gongyu+", "+sh.other_cities+"<br/>"+sh.province_name+", "+sh.country_name+" "+sh.you_code);
                $(".shdz").removeClass("hide");
                $("#shno").addClass("hide");
            }else{
                $("#shno").removeClass("hide");
            }
            getYunfei();
        },function(res,err){})
    }
    //获取运费
    function getYunfei(){
        var p ={
            token:token,
            f_way:f_way,
            sh_id:psh_id,
            shopid:shopid,
            total_yunfei:total_yunfei,
            is_hexiaojia:is_hexiaojia,      //int 是   是核销价
            no_hexiaojia:no_hexiaojia,      //int 是   不是核销价
            sumweight:sumweight,            //float   是   总重量
            carid:param.ids,
            //orderid:orderid, int 否   订单id
            //buygain:orderid, int 否   是否是再次购买 1 是
        }
        pop.loading();
        getAjax(Interface.send_money,p,function(res){
            api.hideProgress();
            $(".odBox3 li").eq(1).find("div").html('$'+Number(res.data.g_sui).toFixed(2));
            $(".odBox3 li").eq(2).find("div").html('$'+Number(res.data.p_sui).toFixed(2));
            $(".odBox3 li").eq(4).find("div").html('$'+Number(res.data.send_money).toFixed(2));
            var sum = Number(sum_price) + Number(res.data.g_sui) + Number(res.data.p_sui) +Number(res.data.send_money) - Number(youhuiq) - Number(sum_youhui);
            $(".wareOrderFooter .c_main").html("$"+sum.toFixed(2));
        },function(res,err){})
    }
    //计算时间戳 //时间戳为10位需*1000，时间戳为13位的话不需乘1000
    function timestampToTime(timestamp) {
    
        var date = new Date(timestamp * 1000);
        Y = date.getFullYear() + '-';
        M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
        D = date.getDate() + ' ';
        return Y+M+D;
    }
    //时间选择
    var currYear = (new Date()).getFullYear();
    var opt={};
    var l='zh';
    if(cnen ==2){
        l='en';
    }
    var today = "重置";
    if(cnen ==2){
        today='Today';
    }
    opt.date = {preset : 'date'};
    opt.datetime = {preset : 'datetime'};
    opt.time = {preset : 'time'};
    opt.default = {
        theme: 'android-ics light', //皮肤样式
        display: 'modal', //显示方式
        mode: 'scroller', //日期选择模式
        dateFormat: 'yyyy-mm-dd',
        lang: l,
        showNow: true,
        nowText: today,
        minDate: new Date(),  //无法选择以前的时间
        startYear: currYear , //开始年份
    };

    var optDateTime = $.extend(opt['date'], opt['default']);
    $("#appDateTime").mobiscroll(optDateTime);
    $(".time").click(function(){$("#appDateTime").click()});
    function choosecity(){
        //选择国家后回调
        api.addEventListener({
            name: 'chooseloading'
        }, function(ret, err) {
            var data =ret.value;
            $("#guojia").val(data.id);
            $("#cgj span").html(data.name);
            $("#sf").val('0');
            $("#chengshi").val('0');
            $("#csf span").html('请选择省份');
            if(cnen==2){
                $("#csf span").html('Province');
            }
            $("#ccs span").html('请选择城市');
            if(cnen==2){
                $("#ccs span").html('City');
            }
        });
        //选择省份
        api.addEventListener({
            name: 'province'
        }, function(ret, err) {
            var data =ret.value;
            $("#sf").val(data.id);
            $("#csf span").html(data.name);
            $("#chengshi").val('0');
            $("#ccs span").html('请选择城市');
            if(cnen==2){
                $("#ccs span").html('City');
            }
          
        });
        //选择城市
        api.addEventListener({
            name: 'choosecity'
        }, function(ret, err) {
            var data =ret.value;
            $("#chengshi").val(data.id);
            $("#ccs span").html(data.name);
            pop.loading();
            console.log(data.id);
            getAjax(Interface.ziti_addr,{city_id:data.id},function(res){
                pop.close();
                console.log(JSON.stringify(res));
                if(res.data==null){
                    msg = '该地区没有我们的门店';
                    if(cnen==2){
                        msg='There are no stores in this city. Please choose again';
                    }
                    pop.notice(msg);
                }else{
                    var list = res.data;
                    var html = '';
                    $.each(list,function(i,item){
                        html +='<li onclick="ziti('+item.id+',\''+item.address+'\')" >'+item.address+'</li>';
                    })
                    $(".zitilist").html(html);
                }
            },function(res,err){})
        });
    }

    function ziti(id,address){
        ziti_addr = id;
        maskClose();
        $(".pop_Item").addClass("dn");
        $(".addressBox1").eq(0).hide();
        $(".addressBox1").eq(1).hide();
        $(".addressBox1").eq(2).show();
        $(".pageTitle").eq(1).hide();
        $(".pageTitle").eq(2).hide();
        $(".ztdz .phone").text();
        $(".ztdz .item2").html(address);
        
    }

</script>
<script type="text/javascript">
   
    function ifCnAndEn(){
        if(cnen==2){
           $(".pageTitle").eq(0).html("Shipping Information");
           $(".eng_title").eq(0).html('Billing Address');
           $(".eng_title").eq(1).html('Delivered to');
           $(".eng_title").eq(2).html('Preferred Delivery Date');
           // $(".eng_title").eq(2).css("font-size","0.2rem");
           $(".eng_title").eq(3).html('Delivery Methods');
           $(".eng_title").eq(4).html('Order Note');
           $(".eng_title").eq(5).html('Coupon');
           $(".reAddress").html("<i></i>Same as billing address");
           $("#appDateTime").attr('placeholder',"Please select a date");
           $(".coupon_btn").html('Apply a coupon<i></i>');
           var psfunction = '<option value="1" selected="selected">Delivered to Person</option>'+
                            '<option value="2">Leave at the Door</option>'+
                            '<option value="3">Self Pickup</option>'+
                            '<option value="4">Mail</option>';
            $(".psfunction").html(psfunction);
            $(".odBox3 li").eq(0).find("span").html('Total Amount');
            $(".odBox3 li").eq(3).find("span").html('Discount');
            $(".odBox3 li").eq(4).find("span").html('Shipping Fee');
            $(".odBox3 li").eq(5).find("span").html('Coupon Discount');
            $("textarea").attr('placeholder','You can leave your notes here.');
            $("#zitiPop_title").html('Select Pick-up Location');
            $(".ztBox").eq(0).find("span").html('Country');
            $(".ztBox").eq(1).find("span").html('Province');
            $(".ztBox").eq(2).find("span").html('City');
            $("#coupon_pop_title").html('Is your current order added to the unshipped order?');
            $(".zjorder_box1").html('Yes');
            $(".zjorder_box2").html('No');
            $(".submitBtn").html("Go to payment");
            $(".footLeft").html('Amount payable:<span style="margin-left:0.1rem" class="c_main">$0</span>');
            $(".couponCode_btn").html('Use discount codes');
            $("#couponCode_input").attr("placeholder",'Please enter the discount code.');
            $(".notyhq").html("Cancel");
        }
    }
</script>
</html>
